<template>
	<view class="">
		<view class="mainpadding">
			<view class="mainpadding radius margin_top ffffff" v-for="item in list.data" :key="item.id" @click="jumpdetail('/pages_homepage/gonggaoxq?id=',item.id)">
				<view class="ershil xiaohei nofonweight">{{item.name}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				// #ifdef H5
				menutop: 80,
				// #endif
				// #ifdef MP-WEIXIN
				menutop: 0,
				// #endif	
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			// #ifdef MP-WEIXIN
			this.menutop = uni.getMenuButtonBoundingClientRect().top * 2
			// #endif
			this.type = options.type
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
				}
				let url = '/api/index/noticeIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转公告详情
			tzggxq(id) {
				uni.navigateTo({
					url: '/pages_homepage/gonggaoxq?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.margin_top:first-child {
		margin-top: 0;
	}

	page {
		background: #f5f5f5;
	}
</style>